package cn.cubix.flow.controller.dto.workflow;

import lombok.Data;
import lombok.experimental.Accessors;
import org.flowable.task.api.Task;

import java.util.Date;
import java.util.Map;

@Data
@Accessors(chain = true)
public class TodoTaskDto {
    protected String id;
    protected String name;
    protected String description;
    protected Integer priority;
    protected String owner;
    protected String assignee;
    protected String processInstanceId;
    protected String executionId;
    protected String taskDefinitionId;
    protected String processDefinitionId;
    protected String scopeId;
    protected String subScopeId;
    protected String scopeType;
    protected String scopeDefinitionId;
    protected String propagatedStageInstanceId;
    protected Date createTime;
    protected String taskDefinitionKey;
    protected Date dueDate;
    protected String category;
    protected String parentTaskId;
    protected String tenantId;
    protected String formKey;
    protected Map<String, Object> taskLocalVariables;
    protected Map<String, Object> processVariables;
    protected Date claimTime;

    public static TodoTaskDto from(Task task){
        return new TodoTaskDto()
                .setId(task.getId())
                .setName(task.getName())
                .setDescription(task.getDescription())
                .setPriority(task.getPriority())
                .setOwner(task.getOwner())
                .setAssignee(task.getAssignee())
                .setProcessInstanceId(task.getProcessInstanceId())
                .setExecutionId(task.getExecutionId())
                .setTaskDefinitionId(task.getTaskDefinitionId())
                .setProcessDefinitionId(task.getProcessDefinitionId())
                .setScopeId(task.getScopeId())
                .setSubScopeId(task.getSubScopeId())
                .setScopeType(task.getScopeType())
                .setScopeDefinitionId(task.getScopeDefinitionId())
                .setPropagatedStageInstanceId(task.getPropagatedStageInstanceId())
                .setCreateTime(task.getCreateTime())
                .setTaskDefinitionKey(task.getTaskDefinitionKey())
                .setDueDate(task.getDueDate())
                .setCategory(task.getCategory())
                .setParentTaskId(task.getParentTaskId())
                .setTenantId(task.getTenantId())
                .setFormKey(task.getFormKey())
                .setTaskLocalVariables(task.getTaskLocalVariables())
                .setProcessVariables(task.getProcessVariables())
                .setClaimTime(task.getClaimTime());

    }


}
